stylecontext: Always warn on style mismatch
authorBenjamin Otte <otte@redhat.com>
Fri, 6 Nov 2015 17:57:24 +0000 (18:57 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 6 Nov 2015 17:59:15 +0000 (18:59 +0100)
For now, always warn when
gtk_style_context_get()/get_padding()/get_margin()/get_border()
get called with the wrong state.

We used to hide this behind an env var because the warnings were
too frequent, but with the recent refactorings, this warning has become
rather important for detecting bugs.

If it's still problematic, we might want to revert this patch before
3.20.

gtk/gtkstylecontext.c

index e5fa5f2fa59316e895d58a337053ebaeb539af85..46be12c0f9e86c61b1f2c52f77efe99800faab2a 100644 (file)
@@ -490,27 +490,25 @@ gtk_style_context_push_state (GtkStyleContext *context,
 {
   GtkStyleContextPrivate *priv = context->priv;
   GtkStateFlags current_state;
+  GtkCssNode *root;
 
   current_state = gtk_css_node_get_state (priv->cssnode);
 
   if (current_state == state)
     return state;
 
-  if (g_getenv ("GTK_STYLE_CONTEXT_WARNING"))
-    {
-      GtkCssNode *root = gtk_style_context_get_root (context);
+  root = gtk_style_context_get_root (context);
 
-      if (GTK_IS_CSS_WIDGET_NODE (root))
-        {
-          GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (root));
-          g_warning ("State %u for %s %p doesn't match state %u set via gtk_style_context_set_state ()",
-                     state, gtk_widget_get_name (widget), widget, gtk_css_node_get_state (priv->cssnode));
-        }
-      else
-        {
-          g_warning ("State %u for context %p doesn't match state %u set via gtk_style_context_set_state ()",
-                     state, context, gtk_css_node_get_state (priv->cssnode));
-        }
+  if (GTK_IS_CSS_WIDGET_NODE (root))
+    {
+      GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (root));
+      g_warning ("State %u for %s %p doesn't match state %u set via gtk_style_context_set_state ()",
+                 state, gtk_widget_get_name (widget), widget, gtk_css_node_get_state (priv->cssnode));
+    }
+  else
+    {
+      g_warning ("State %u for context %p doesn't match state %u set via gtk_style_context_set_state ()",
+                 state, context, gtk_css_node_get_state (priv->cssnode));
     }
 
   gtk_css_node_set_state (priv->cssnode, state);